package org.hxzon.tapestry5.validator;

import org.apache.tapestry5.Field;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.ioc.MessageFormatter;
import org.apache.tapestry5.services.FormSupport;

public class Email extends org.apache.tapestry5.validator.Email {
    public void render(Field field, Void constraintValue, MessageFormatter formatter, MarkupWriter markupWriter, FormSupport formSupport) {

        formSupport.addValidation(field, "email", buildMessage(formatter, field), null);
    }

    private String buildMessage(MessageFormatter formatter, Field field) {
        return formatter.format(field.getLabel());
    }
}
